package com.liliang.controller;

import com.liliang.entity.Material;
import com.liliang.entity.MaterialPage;
import com.liliang.service.IMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liliang
 * @since 2021-11-04
 */
@Controller
@RequestMapping("/material")
public class MaterialController {

    @Autowired
    IMaterialService ims;

    @ResponseBody
    @GetMapping("/findMaterialPage")
    public MaterialPage findMaterialPage(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "5") Integer rows,Material material){
        return ims.findMaterialPage((page-1)*rows,rows,material);
    }

    @PostMapping("/next")
    public String next(HttpServletRequest request, Model model){
        //得到所有id
        String[] nums = request.getParameterValues("nums");
        //通过id找
        List<Material> materials=ims.next(nums);

        model.addAttribute("materials",materials);
        return "planman/Order_newform";
    }







}

